package code.c05;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/9/29 10:53
 * @package code.c05
 * @description 雇员
 */

public class Employee {
    private String id;
    private String name;

    public Employee() {
    }

    public Employee(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    @Override
    public String toString() {
        return "id='" + id + '\'' + ", name='" + name + '\'';
    }
}

class FullTimeEmployee extends Employee {
    private Double monthlyPay;

    public FullTimeEmployee(Double monthlyPay) {
        this.monthlyPay = monthlyPay;
    }

    public FullTimeEmployee(String id, String name, Double monthlyPay) {
//        super(id, name);
        super.setId(id);
        super.setName(name);

        this.monthlyPay = monthlyPay;
    }

    public Double getMonthlyPay() {
        return monthlyPay;
    }

    public void setMonthlyPay(Double monthlyPay) {
        this.monthlyPay = monthlyPay;
    }

    @Override
    public String toString() {
        return "FullTimeEmployee{" + '\'' + super.toString() + ", monthlyPay=" + monthlyPay  + '}';
    }

    /**
     * 计算一年的收益
     * @return
     */
    public double calculatetYearPay(){
        return monthlyPay * 12;
    }
}

class PartTimeEmployee extends Employee  {
    double hourlyPay;

    // 构造方法
    public PartTimeEmployee(double hourlyPay) {
        this.hourlyPay = hourlyPay;
    }
    public PartTimeEmployee(String id, String name, double hourlyPay) {
        super(id, name);
        this.hourlyPay = hourlyPay;
    }

    // get && set
    public double getHourlyPay() {
        return hourlyPay;
    }

    public void setHourlyPay(double hourlyPay) {
        this.hourlyPay = hourlyPay;
    }

    @Override
    public String toString() {
        return "PartTimeEmployee{" + '\'' + super.toString() + ", hourlyPay=" + hourlyPay  + '}';
    }

    /**
     * 计算一年的收益
     * @param hours
     * @return
     */
    public double calculatetWeekPay(int hours){
        return hourlyPay * hours;
    }
}

class TestEmployee {
    public static void main(String[] args) {
        Employee em1 = new Employee("1002", "zhang san");
        System.out.println(em1.toString());

        PartTimeEmployee em2 = new PartTimeEmployee("1001", "li si", 40);
        System.out.println(em2.toString());
        System.out.println(em2.calculatetWeekPay(56));

        FullTimeEmployee em3 = new FullTimeEmployee("1003", "wang wu", (double) 3200);
        System.out.println(em3.toString());
        System.out.println(em3.calculatetYearPay());
    }
}